# == Schema Information
#
# Table name: dorm_users
#
#  id               :bigint           not null, primary key
#  act_electric_pay :decimal(, )
#  act_water_pay    :decimal(, )
#  day_count        :integer
#  name             :string
#  pay_balance      :decimal(, )
#  created_at       :datetime         not null
#  updated_at       :datetime         not null
#  dorm_id          :integer
#  hydropower_id    :integer
#
# Indexes
#
#  index_dorm_users_on_dorm_id        (dorm_id)
#  index_dorm_users_on_hydropower_id  (hydropower_id)
#
class DormUser < ApplicationRecord
  belongs_to :dorm
  belongs_to :hydropower

  def water_pay
    total_water = self.hydropower.water_balance
    avatage = (total_water / self.dorm_users.count).round(2)

  end
end
